package com.ruoyi.retirement.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.retirement.domain.RetirementArticle;
import com.ruoyi.retirement.mapper.RetirementArticleMapper;
import com.ruoyi.retirement.service.IRetirementArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 文章发布Service业务层处理
 * 
 * @author 曹旭
 * @date 2025-09-02
 */
@Service
public class RetirementArticleServiceImpl implements IRetirementArticleService
{
    @Autowired
    private RetirementArticleMapper retirementArticleMapper;

    /**
     * 查询文章发布
     * 
     * @param id 文章发布主键
     * @return 文章发布
     */
    @Override
    public RetirementArticle selectRetirementArticleById(Long id)
    {
        return retirementArticleMapper.selectRetirementArticleById(id);
    }

    /**
     * 查询文章发布列表
     * 
     * @param retirementArticle 文章发布
     * @return 文章发布
     */
    @Override
    public List<RetirementArticle> selectRetirementArticleList(RetirementArticle retirementArticle)
    {
        return retirementArticleMapper.selectRetirementArticleList(retirementArticle);
    }

    @Override
    public List<RetirementArticle> selectRetirementArticleListMiniApp(RetirementArticle retirementArticle) {
        return retirementArticleMapper.selectRetirementArticleListMiniApp(retirementArticle);
    }

    /**
     * 新增文章发布
     * 
     * @param retirementArticle 文章发布
     * @return 结果
     */
    @Override
    public int insertRetirementArticle(RetirementArticle retirementArticle)
    {
        retirementArticle.setIsDel("0");
        retirementArticle.setCreateTime(DateUtils.getNowDate());
        return retirementArticleMapper.insertRetirementArticle(retirementArticle);
    }

    /**
     * 修改文章发布
     * 
     * @param retirementArticle 文章发布
     * @return 结果
     */
    @Override
    public int updateRetirementArticle(RetirementArticle retirementArticle)
    {
        retirementArticle.setUpdateTime(DateUtils.getNowDate());
        return retirementArticleMapper.updateRetirementArticle(retirementArticle);
    }

    /**
     * 批量删除文章发布
     * 
     * @param ids 需要删除的文章发布主键
     * @return 结果
     */
    @Override
    public int deleteRetirementArticleByIds(Long[] ids)
    {
        for(int i=0;i<ids.length;i++){
            retirementArticleMapper.deleteRetirementArticleById(ids[i]);
        }
        return 1;
    }

    /**
     * 删除文章发布信息
     * 
     * @param id 文章发布主键
     * @return 结果
     */
    @Override
    public int deleteRetirementArticleById(Long id)
    {
        return retirementArticleMapper.deleteRetirementArticleById(id);
    }

    @Override
    public List<RetirementArticle> selectEnrollList(RetirementArticle retirementArticle) {
        return retirementArticleMapper.selectEnrollList(retirementArticle);
    }

    @Override
    public List<RetirementArticle> selectCollectList(RetirementArticle retirementArticle) {
        return retirementArticleMapper.selectCollectList(retirementArticle);
    }
}
